package game

import (
	"message"
	"github.com/name5566/leaf/gate"
	"github.com/name5566/leaf/log"
)


// 注册消息处理
func Register(msgID message.MSG, handler func([]interface{})) {
	skeleton.RegisterChanRPC(msgID, handler)
}

// 通过连接寻找对应的玩家
func GetUserByAgent(agent interface{}) (*User) {
	account := agent.(gate.Agent).UserData().(*AgentInfo).Account
	return account2Users[account]
}

// 通过账号寻找对应的玩家
func GetUserByAccount(account string) (*User) {
	return account2Users[account]
}

// 打印所有的在线玩家
func PrintUsersOnline() {
	log.Debug("printUsersOnline:  %v", users)
	log.Debug("printUsersOnline account:  %v", account2Users)
}
